package AsLayers.BaseType
{
	public class Pixel
	{
		public var x:Number;
		public var y:Number;
		public function Pixel(x:Number,y:Number){
			this.x=x;
			this.y=y;
		}
		    /**
     * Method: toString
     * Cast this object into a string
     *
     * Returns:
     * {String} The string representation of Pixel. ex: "x=200.4,y=242.2"
     */
       public function toString():String {
           return ("x=" + this.x + ",y=" + this.y);
       }

    /**
     * APIMethod: clone
     * Return a clone of this pixel object
     *
     * Returns:
     * {<Pixel>} A clone pixel
     */
       public function clone():Pixel {
          return new Pixel(this.x, this.y); 
       }
    
    /**
     * APIMethod: equals
     * Determine whether one pixel is equivalent to another
     *
     * Parameters:
     * px - {<Pixel>}
     *
     * Returns:
     * {Boolean} The point passed in as parameter is equal to this. Note that
     * if px passed in is null, returns false.
     */
        public function equals(px:Pixel):Boolean {
          var equals:Boolean = false;
          if (px != null) {
              equals = (this.x == px.x && this.y == px.y);
          }
          return equals;
        }

    /**
     * APIMethod: add
     *
     * Parameters:
     * x - {Integer}
     * y - {Integer}
     *
     * Returns:
     * {<Pixel>} A new Pixel with this pixel's x&y augmented by the 
     * values passed in.
     */
       public function add(x:Number, y:Number):Pixel {
           return new Pixel(this.x + x, this.y + y);
       }

    /**
    * APIMethod: offset
    * 
    * Parameters
    * px - {<Pixel>}
    * 
    * Returns:
    * {<Pixel>} A new Pixel with this pixel's x&y augmented by the 
    *                      x&y values of the pixel passed in.
    */
       public function offset(px:Pixel):Pixel {
           var newPx:Pixel = this.clone();
           if (px) {
              newPx = this.add(px.x, px.y);
           }
           return newPx;
       }
	}
}